package com.example.xjtuse_pc.mobilesafe;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;

public class KSoapActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ksoap);
    }

    public void Soap(View view) {
        new Thread(new Runnable() {
            @Override
            public void run() {
				try {
					String url = "http://ws.webxml.com.cn/WebServices/WeatherWS.asmx?wsdl";
					String ns = "http://WebXml.com.cn";
					String action = "getRegionProvince";
					HttpTransportSE trans = new HttpTransportSE(url);
					SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
					SoapObject body = new SoapObject(ns, action);
					envelope.setOutputSoapObject(body);
					envelope.dotNet = true;
					trans.call(ns + "/" + action, envelope);
					System.out.println(envelope.bodyIn.getClass().getName());
					System.out.println(envelope.getResponse().getClass().getName());
					SoapObject so = (SoapObject) envelope.getResponse();
					for (int i = 0; i < so.getPropertyCount(); i++) {
						Log.i("join",so.getProperty(i).toString());
					}

				} catch (Exception e) {

				}
			}

        }).start();
    }
}
